<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 调度新增首页</title>
    <meta name="keywords" content="ZDH 调度新增首页">
    <meta name="description" content="ZDH 调度新增首页">

    <link rel="shortcut icon" href="img/favicon.ico">

    <link href="css/plugins/chosen/chosen.css" rel="stylesheet">
<!--    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">-->
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="css/plugins/datetimepicker/datetimepicker.css" rel="stylesheet">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>调度任务配置</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">

                    <form id="dispatch_task_add_form" name="dispatch_task_add_form" method="post" class="form-horizontal"
                          action="">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">SHELL说明</label>
                            <div class="col-sm-10">
                                <input id="etl_context" name="etl_context" type="text"
                                       placeholder="SHELL说明" class="form-control" aria-required="true"> </span>
                            </div>
                            <label class="col-sm-2 control-label">是否脚本</label>
                            <div class="col-sm-10">
                                <div class="checkbox i-checks">
                                    <label class="no-padding">
                                        <input id="is_script" type="checkbox"><i></i> 脚本方式</label>
                                </div>
                            </div>
                            <label class="col-sm-2 control-label">任务命令</label>
                            <div class="col-sm-10">
                                <textarea id="command" name="command" rows="5"
                                          placeholder="SHELL命令,JDBC命令" class="form-control" aria-required="true" ></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否禁用</label>
                            <div class="col-sm-10">
                                <div class="checkbox i-checks">
                                    <label class="no-padding">
                                        <input id="is_disenable" name='is_disenable'  type="checkbox"><i></i> 禁用</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">依赖级别</label>
                            <div class="col-sm-10">
                                <select id="depend_level" name="depend_level" data-placeholder="依赖级别"
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="0" mytype="">成功触发</option>
                                    <option value="1" mytype="">杀死触发</option>
                                    <option value="2" mytype="">失败触发</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="text-center">
                                <button id="save_etl_info" name="save_etl_info" class="btn btn-primary" οnsubmit='return false'
                                        type="button">保存
                                </button>
                            </div>
                        </div>

                    </form>


                </div>
            </div>



        </div>
    </div>
</div>



<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- Bootstrap table -->
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

<!-- 自定义js -->
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="js/hplus.js?v=4.1.0"></script>
<script src="js/content.js?v=1.0.0"></script>

<!-- Chosen -->
<script src="js/plugins/chosen/chosen.jquery.js"></script>

<!-- layer javascript -->
<script src="js/plugins/layer/layer.min.js"></script>

<!-- Toastr script -->
<script src="js/plugins/toastr/toastr.min.js"></script>

<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>

<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>

<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>

<script src="js/plugins/layer/laydate/laydate.js"></script>

<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });

    });

    (function(document, window, $) {


        (function () {

            var url = decodeURI(location.search); //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
            var params = url.substr(1);//去掉问号
            var pa = params.split("&");
            var s = new Object();
            for(var i = 0; i < pa.length; i ++){
                s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
            }
            $('#depend_level').chosen()
            if(s.command != '-1'){
                console.info("更新触发")
                if( s.is_script=="true"){
                    $('#is_script').iCheck('check');
                }
                $("#command").val($("#shell_text",window.parent.document).val());
                $("#etl_context").val(s.etl_context);
                $("#depend_level").val(s["depend_level"]);
                $("#depend_level").trigger("chosen:updated");

                var is_disenable=s['is_disenable']
                if(is_disenable=="true"){
                    $('#is_disenable').iCheck('check');
                }

            }
        })();



    })(document, window, jQuery);

    $('#save_etl_info').click(function () {

        //自定义实现
        var command=$('#command').val();
        var is_script="false"
        if($('#is_script').is(':checked')){
            is_script="true"
        }
        var is_disenable = "false"
        if($('#is_disenable').is(':checked')){
            is_disenable="true"
        }
        var depend_level=$('#depend_level').find("option:selected").val();

        var etl_context=$('#etl_context').val();
        data={
            "command":command,
            "is_script":is_script,
            "etl_context":etl_context,
            "is_disenable":is_disenable,
            "depend_level":depend_level
        }
        console.info("shell_detail:"+JSON.stringify(data))
        $("#etl_task_text",window.parent.document).val(JSON.stringify(data));
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })
</script>


</body>

</html>
